#include"BSTree.h"

int BinSearch(Search* arr, int n, KeyType x)
{
	int left, right, mid;
	left = 0;
	right = n - 1;
	mid = (left + right) / 2;
	while (left <= right)
	{
		if (arr[mid].key == x)
		{
			return mid;
		}
		if (arr[mid].key < x)
		{
			left = mid + 1;
			mid = (left + right) / 2;
		}
		if (arr[mid].key > x)
		{
			right = mid - 1;
			mid = (left + right) / 2;

		}
	}
	return -1;
}
int main()
{
	Search Search1;
	Search Search2;
	Search Search3;
	Search Search4;
	Search Search5;
	Search1.key = 20;
	Search2.key = 43;
	Search3.key = 65;
	Search4.key = 76;
	Search5.key = 89;
	Search arr[5] = { Search1,Search2,Search3,Search4,Search5 };
	//printf("%d", BinSearch(arr, sizeof(arr) / sizeof(Search), 76));
	BSNode*bt=CreatBST(arr, sizeof(arr) / sizeof(Search));
	printf("%p", BSTSearch(bt, 76));
	return 0;
}